<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div class="idperson">
    <form action="">
      <input type="radio" name="identity" value="学生">学生
      <input type="radio" name="identity" value="老师" checked="checked">老师
      <input type="radio" name="identity" value="管理员">管理员
    </form>
  </div>
  <div class="">用户:<input type="text" class="username" placeholder="请输入用户名">
  </div>
  <br>
  <div class="">密码:<input type="text" class="password" placeholder=" 请输入密码">
    <div class=""><button type="submit">登录</button></div>
</body>
<script src="axios-0.18.0.js"></script>
<script>
  const submit = document.querySelector('[type=submit]')
  const username = document.querySelector('.username')
  const password = document.querySelector('.password')
  submit.addEventListener('click', function () {
    // console.log(username.value, password.value);
    // 1.创建对象
    const obj = {
      username: username.value,
      password: password.value
    }
    //   function testpost() {
    //     axios.post('/a', {
    //       "uesername": obj.username,
    //       "password": obj.password
    //     }).then(response => {
    //       console.log('/a1', response.data)
    //     }, error => {
    //       console.log('错误', error.message)
    //     })
    //   }
    //   testpost()
    // })
    axios({
      url: 'http://127.0.0.1:9000',
      method: 'POST',
      data: {
        username,
        password
      }
    }).then(result => {
      console.log(result);
    })
  })
</script>

</body>

</html>